package cn.yuanyu.es.pojo;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @author yuanyu
 */
@Data
/**
 * indexName        : 索引库的名称，建议以项目的名称命名
 * type             : 类型，建议以实体的名称命名
 * shards           : 默认分区数
 * replicas         : 每个分区默认的备份数
 * refreshInterval  : 刷新间隔
 * indexStoreType   : 索引文件存储类型
 */
@Document(indexName = "boot_idx", type = "user", shards = 6, replicas = 1)
public class User {

    /**
     * 必须指定一个id
     */
    @Id
    private Long id;

    @Field(store = true)
    private String name;

    @Field
    private Integer age;

    @Field(analyzer = "ik_smart", type = FieldType.Text)
    private String hobby;


    public User() {
    }

    public User(Long id, String name, Integer age, String hobby) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.hobby = hobby;
    }
}
